package com.example.graduationdesign.exception;


import com.example.graduationdesign.pojo.vo.Result;
import com.example.graduationdesign.pojo.vo.ResultCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    // 自定义异常
    @ExceptionHandler(CustomizeException.class)
    @ResponseBody
    public Result<ResultCode> error(CustomizeException e) {
        return Result.failure(e.getResultCode());
    }
}
